home *** CD-ROM | disk | FTP | other *** search
- ' This form demonstrates how to upload files to a server
-
- Public Class HtmlControlsForm
- Inherits System.Web.UI.Page
- Protected WithEvents File1 As System.Web.UI.HtmlControls.HtmlInputFile
- Protected WithEvents DIV1 As System.Web.UI.HtmlControls.HtmlGenericControl
- Protected WithEvents Button1 As System.Web.UI.HtmlControls.HtmlInputButton
-
- #Region " Web Form Designer Generated Code "
-
- 'This call is required by the Web Form Designer.
- <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
-
- End Sub
-
- Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
- 'CODEGEN: This method call is required by the Web Form Designer
- 'Do not modify it using the code editor.
- InitializeComponent()
- End Sub
-
- #End Region
-
- Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- 'Put user code to initialize the page here
- End Sub
-
- ' this procedure fires when the form is submitted
- ' it reads and displays data about the file that has been uploaded
- ' and saves the file itself to c:\file.dat
-
- Private Sub Button1_ServerClick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.ServerClick
- Dim msg As String
- If Not File1.PostedFile Is Nothing Then
- msg = "<b>Filename = </b>" & File1.PostedFile.FileName & "<br>"
- msg &= "<b>ContentLength = </b>" & File1.PostedFile.ContentLength & "<br>"
- msg &= "<b>ContentType = </b>" & File1.PostedFile.ContentType & "<br>"
- File1.PostedFile.SaveAs("C:\file.dat")
- msg &= "File has been saved on the server"
- Else
- msg = "No file has been posted"
- End If
-
- ' display information in the Div1 control.
- DIV1.InnerHtml = msg
- End Sub
-
- End Class
-